<template>
  <div class="farmland-edit f-c">
    <div class="top">
      <div class="top-back" @click="back">
        <i class="el-icon-arrow-left" />
        返回
      </div>
      编辑田块
    </div>
    <div class="f-g map-container">
      <Map ref="map" @set-area="onSetArea" />
    </div>
    <MapTool />
  </div>
</template>

<script>
import Map from '@/views/farmland/map';
export default {
  name: 'FarmalndEdit',
  components: {
    Map
  },
  data() {
    return {
      drawer: false,
      searchInput: '',
      ruleForm: {
        area: '',
        perimeter: ''
      },
      options: [],
      buttonRight: '30px',
      right: '-500px',
      // 开始圈田
      drawerType: '',
      isDrawer: false,
      // 绘制提示
      showTips: false,
      // 去新增
      showAdd: false,
      detail: {
        area: '',
        perimeter: ''
      }
    }
  },
  methods: {
    onSelectArea() {
      this.drawerType = 'start'
      this.$refs.map.startDrawer()
    },
    onClearMap() {
      this.$refs.map.map.clearMap()
      this.detail = {
        area: '',
        perimeter: ''
      }
    },
    onSetArea({ area, perimeter }) {
      this.showTips = true
      this.detail.area = area
      this.detail.perimeter = perimeter
    },
    onDelete() {
      this.$refs.map.map.clearMap()
      this.showTips = false
      this.detail = {
        area: '',
        perimeter: ''
      }
    },
    openAdd() {
      this.showAdd = true
      this.right = '0px'
      this.buttonRight = '530px'
      // 设置添加表单
      this.ruleForm = {
        ...this.detail
      }
    },
    closeAdd() {
      this.showAdd = false
      this.right = '-500px'
      this.buttonRight = '30px'
    },
    back() {
      this.$router.back()
    }
  }
}
</script>

<style scoped lang="scss">
.farmland-edit {
  height: 100%;
  .top {
    margin-top: -10px;
    margin-bottom: 10px;
    width: 100%;
    height: 63px;
    background: #ffffff;
    border-radius: 2px;
    position: relative;
    text-align: center;
    font-size: 18px;

    font-weight: 600;
    line-height: 63px;
    color: #333333;
    .top-back {
      cursor: pointer;
      position: absolute;
      left: 18px;
      top: 50%;
      transform: translateY(-50%);
      i {
        font-size: 15px;
        color: #333333;
      }
      font-size: 16px;

      font-weight: 400;
      line-height: 22px;
      color: #333333;
      opacity: 1;
    }
  }
  .map-container {
    overflow: hidden;
    position: relative;
    .edit-btn {
      position: absolute;
      right: 36px;
      top: 20px;
      z-index: 99;
    }
  }
  .farmland-edit-drawer {
    position: absolute;
    height: 100%;
    top: 0;
    z-index: 100;
    transition: all 0.3s;
    .drawer-content {
      overflow: auto;
      height: 100%;
      background-color: #ffffff;
      width: 500px;
      padding: 20px;
      ::v-deep .el-form {
        .el-form-item {
          .el-input,
          .el-select {
            width: 100% !important;
          }
        }
      }
    }
    .form-value {
      font-size: 14px;

      font-weight: 400;
      line-height: 20px;
      color: #333333;
      padding: 0 20px;
    }
    i {
      position: absolute;
      right: 20px;
      top: 12px;
      color: #2b2f3a;
      font-size: 24px;
    }
  }
  .search-box {
    position: absolute;
    left: 64px;
    top: 28px;
    z-index: 20;
    ::v-deep .el-input {
      width: 722px !important;
      background: rgba(255,255,255,0.39);
      opacity: 0.74;
      margin-right: 15px;
    }
  }
  .showTips {
    width: 100%;
    height:130px;
    position: absolute;
    left: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    padding: 0 67px 0 97px;
    z-index: 99;
    .item-list {
      .item {
        margin-right: 100px;
        font-size: 14px;

        font-weight: bold;
        line-height: 24px;
        color: #FFFFFF;
      }
    }
  }
}
</style>
